package com.yxw.live_vod_backend_boot.service.impl;

import com.yxw.yxnet_cd_center.common.enums.CreateTableEnum;
import com.yxw.live_vod_backend_boot.entity.SysOptLogEntity;
import com.yxw.live_vod_backend_boot.mapper.LogMapper;
import com.yxw.live_vod_backend_boot.service.CreateTableService;
import com.yxw.live_vod_backend_boot.service.LogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * 创建表service
 * @author liuxin
 * @date 2023.09.25
 */
@Slf4j
@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private CreateTableService createTableService;

    @Autowired
    private LogMapper logMapper;

    /**
     * 推送记录保存
     * @param entity
     */
    @Override
    @Async(value ="optlog-executor")
    public void addOptLog(SysOptLogEntity entity) {
        if(null!=entity){
            try{
                //创建记录表
                String tableName = createTableService.createTable(CreateTableEnum.SYS_OPT_LOG);
                logMapper.addOptLog(entity,tableName);
            }catch (Exception e){
                log.error("记录参错日志出错{}",e);
            }
        }
    }
}
